package com.java.yz.day11.ketang;

import java.util.HashSet;
import java.util.Set;

//存储自定义对象并遍历
public class SetDemo2 {
    public static void main(String[] args) {
        //创建集合对象
        Set<Student> set = new HashSet<>();
        //创建学生对象  添加到集合中
        set.add(new Student("张三",19));
        set.add(new Student("李四",21));
        set.add(new Student("王五",20));

        //遍历学生对象
        for (Student student : set) {
            System.out.println(student);
        }
    }
}
